﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model.Custome;
using Framework.Common;
using Framework;

namespace DomPrint
{
    public partial class HDDomShowForm : BaseShowForm
    {
        MediumType TypeName;
        TapeType TapeType;

        public HDDomShowForm(int printNum, List<ListItemInfo> listItem, MediumType mediumType)
            : base(printNum, listItem)
        {
            InitializeComponent();
            this.TypeName = mediumType;
        }

        public HDDomShowForm(int printNum, List<ListItemInfo> listItem, MediumType mediumType, TapeType tapeType)
            : base(printNum, listItem)
        {
            InitializeComponent();
            this.TypeName = mediumType;
            this.TapeType = tapeType;
        }

        private void HDDomShowForm_Load(object sender, EventArgs e)
        {
            try
            {
                LogHelper.DebugFormat("打印{0}", TypeName.ToString());
                switch (TypeName)
                {
                    case MediumType.HD:
                        this.Text = "硬盘";
                        break;
                    case MediumType.Tape:
                        this.Text = "SLR磁带";
                        break;
                    case MediumType.CD:
                        this.Text = "CD";
                        break;
                    case MediumType.DVD:
                        this.Text = "DVD";
                        break;
                    case MediumType.Other:
                        this.Text = "其它介质";
                        break;
                }

                PrintPrepare();
                foreach (ListItemInfo item in listItem)
                {
                    string text = "";
                    if (TypeName == MediumType.Tape && TapeType == Framework.Common.TapeType.SLR)
                    {
                        text = item.CDTXM;
                        lblDocType.Text = item.CDBH.IsNotEmpty() ? "磁带编号:" + item.CDBH : "";
                        lblDept.Text = item.BYRQ.IsNotEmpty() ? "数据类型:" + item.BYRQ : "";
                        lblDate.Text = item.BYRQ.IsNotEmpty() ? "备份日期:" + item.BYRQ : "";
                    }
                    else
                    {
                        text = item.JZBH;
                        lblDocType.Text = item.ZLMC.IsNotEmpty() ? item.ZLMC : "";
                        lblDept.Text = item.TGDW.IsNotEmpty() ? item.TGDW : "";
                        lblDate.Text = item.TGRQ.IsNotEmpty() ? item.TGRQ : "";
                    }
                    lblSerialNo.Text = item.JZLSH.IsNotEmpty() ? "流水号:" + item.JZLSH : "";
                    Bitmap map = GetBarCode(text);
                    pictureBox1.Image = map;

                    DoPrint();
                }
                //this.Close();
            }
            catch (Exception ex)
            {
                LogHelper.ErrorFormat("HDDomShowForm Load exception:{0}{1}", ex.Message, ex.StackTrace);
            }

        }

    }
}
